<?php
class Visitor extends AppModel {

	var $name = 'Visitor';
    var $primaryKey = 'visitor_id';
    var $actsAs = array('Containable');
    var $hasMany = array('Comment');


    /**
     * Checking visitor status
     * usage in Comment Controller -> function addComment()
     */
    public function checkVisitor($email){
        $this->recursive = -1;
        $result = $this->find('first',array(
            'conditions'=>array('Visitor.email'=>$email),
            'fields'=>'Visitor.status'
        ));

        return $result;
    }

    /**
     * Cheking email whether register or not
     * usage in Visitor Controller -> function approve(), function spam(), function deny()
     */
    function checkEmail($email){
        $this->recursive = -1;
        $result = $this->find('first',array(
            'conditions'=>array('Visitor.email'=>$email),
            'fields'=>'Visitor.visitor_id'
        ));

        return $result;
    }
 }
?>